<?php
include_once('connection/connection.php');
include('header.php');
include('menu.php');
include('config.php');
//$block=$_SESSION['form_id'];
$district=$_SESSION['district'];

function risk_analysis($dist,$source,$q1)
{
	$sqlStorage="SELECT count(*) FROM `tbl_dtls_q3_last` a,tbl_dtls_q3_loc b where a.source_type like '".$source."%' and a.$q1='YES' and a.loc_id=b.id and b.district_id='".$dist."'";
	$queryStorage=mysql_query($sqlStorage);
	$rowStorage=mysql_fetch_row($queryStorage);
	return $rowStorage[0];
}
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
<style type="text/css">
.style10 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; color:#000000}
.style11 {font-size: 9px}
</style>
</head>
<body>
<table border="0" width="521" cellspacing="0" cellpadding="0">
	<tr>
		<td width="521" height="26" bgcolor="#E9E9E9">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
	  <font face="Verdana" color="#224568">Top Risk Analysis for sanitary form</font></span></td>
	</tr>
	
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="520" cellspacing="0" cellpadding="0" height="61" bgcolor="#C5D8EB">
			<tr>
				
				<td width="200" align="center">
				<font face="Verdana" style="font-size: 8.5pt" color="#000000">Source type</font></td>
				
				<td width="314" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt" color="#000000">
			  Top3 risk</font></td>
			</tr>
			
		</table>		</td>
	</tr>
	<tr>
		<td>
		<table border="1" width="520" cellspacing="0" cellpadding="0" height="49" bordercolor="#C5D8EB" style="border: 1px solid #BBD1E8" bgcolor="#F9F9F9">
			
			<tr>
			<?php
		$ques1=risk_analysis($district,HP,risk_analysis_q1);
		//echo $ques1;
		$ques2=risk_analysis($district,HP,risk_analysis_q2);
		$ques3=risk_analysis($district,HP,risk_analysis_q3);
		$ques4=risk_analysis($district,HP,risk_analysis_q4);
		$ques5=risk_analysis($district,HP,risk_analysis_q5);
		$ques6=risk_analysis($district,HP,risk_analysis_q6);
		$ques7=risk_analysis($district,HP,risk_analysis_q7);
		$ques8=risk_analysis($district,HP,risk_analysis_q8);
		$ques9=risk_analysis($district,HP,risk_analysis_q9);
		//$ques10=risk_analysis($district,HP,risk_analysis_q10);
		//$ques11=risk_analysis($district,HP,risk_analysis_q11);
		$arr=array(1 => $ques1, $ques2, $ques3, $ques4, $ques5, $ques6, $ques7, $ques8, $ques9);
		
		
		
		?>
				
				<td width="200" align="center"><span class="style10">HP</span></td>
				
				<td width="314" align="center"><span class="style10">
				<?php 
				if($arr[1]==0 && $arr[2]==0 && $arr[3]==0 && $arr[4]==0 && $arr[5]==0 && $arr[6]==0 && $arr[7]==0 && $arr[8]==0 && $arr[9]==0)
				{
					echo '';
				}
				else
				{
					arsort($arr);
					$num_print=0;
					foreach ($arr as $key => $val) {
					
					echo "Question" . $key . "<br>";
					if (++$num_print == 3) {
					break;
					}
					
					}
				 }
				 ?>
				 </span></td>
			</tr>
			<tr>
			<?php
		$ques1t=risk_analysis($district,TW,risk_analysis_q1);
		
		$ques2t=risk_analysis($district,TW,risk_analysis_q2);
		$ques3t=risk_analysis($district,TW,risk_analysis_q3);
		$ques4t=risk_analysis($district,TW,risk_analysis_q4);
		$ques5t=risk_analysis($district,TW,risk_analysis_q5);
		$ques6t=risk_analysis($district,TW,risk_analysis_q6);
		$ques7t=risk_analysis($district,TW,risk_analysis_q7);
		$ques8t=risk_analysis($district,TW,risk_analysis_q8);
		$ques9t=risk_analysis($district,TW,risk_analysis_q9);
		$ques10t=risk_analysis($district,TW,risk_analysis_q10);
		//$ques11t=risk_analysis($district,TW,risk_analysis_q11);
		$arrt=array(1 => $ques1t, $ques2t, $ques3t, $ques4t, $ques5t, $ques6t, $ques7t, $ques8t, $ques9t, $ques10t);
		
		
		
		?>
			
			<td width="200" align="center"><span class="style10">TW</span></td>
				
				<td width="314" align="center"><span class="style10">
				<?php 
				if($arrt[1]==0 && $arrt[2]==0 && $arrt[3]==0 && $arrt[4]==0 && $arrt[5]==0 && $arrt[6]==0 && $arrt[7]==0 && $arrt[8]==0 && $arrt[9]==0 && $arrt[10]==0)
				{
					echo '';
				}
				else
				{
					arsort($arrt);
					$num_print=0;
					foreach ($arrt as $keyt => $valt) {
					echo "Question" . $keyt . "<br>";
					if (++$num_print == 3) {
					break;
					}
					
					}
				}
				 ?>
				</span></td>
			
			</tr>
			<tr>
			<?php
		$ques1d=risk_analysis($district,DW,risk_analysis_q1);
		//echo $ques1;
		$ques2d=risk_analysis($district,DW,risk_analysis_q2);
		$ques3d=risk_analysis($district,DW,risk_analysis_q3);
		$ques4d=risk_analysis($district,DW,risk_analysis_q4);
		$ques5d=risk_analysis($district,DW,risk_analysis_q5);
		$ques6d=risk_analysis($district,DW,risk_analysis_q6);
		$ques7d=risk_analysis($district,DW,risk_analysis_q7);
		$ques8d=risk_analysis($district,DW,risk_analysis_q8);
		$ques9d=risk_analysis($district,DW,risk_analysis_q9);
		$ques10d=risk_analysis($district,DW,risk_analysis_q10);
		$ques11d=risk_analysis($district,DW,risk_analysis_q11);
		$arrd=array(1 => $ques1d, $ques2d, $ques3d, $ques4d, $ques5d, $ques6d, $ques7d, $ques8d, $ques9d, $ques10d, $ques11d);
		
		
		
		?>
			<td width="200" align="center"><span class="style10">DW</span></td>
				
				<td width="314" align="center"><span class="style10">
				<?php 
				if($arrd[1]==0 && $arrd[2]==0 && $arrd[3]==0 && $arrd[4]==0 && $arrd[5]==0 && $arrd[6]==0 && $arrd[7]==0 && $arrd[8]==0 && $arrd[9]==0 && $arrd[10]==0 && $arrd[11]==0)
				{
					echo '';
				}
				else
				{
					arsort($arrd);
					$num_print=0;
					foreach ($arrd as $keyd => $vald) {
					//echo $arr[0];
					echo "Question" . $keyd . "<br>";
					if (++$num_print == 3) {
					break;
					}
					
					}
				 }
				 ?>
				</span></td>
			
			</tr>
			
				
				
			
			
			<tr>
				<?php
		$ques1r=risk_analysis($district,Rain,risk_analysis_q1);
		//echo $ques1;
		$ques2r=risk_analysis($district,Rain,risk_analysis_q2);
		$ques3r=risk_analysis($district,Rain,risk_analysis_q3);
		$ques4r=risk_analysis($district,Rain,risk_analysis_q4);
		$ques5r=risk_analysis($district,Rain,risk_analysis_q5);
		$ques6r=risk_analysis($district,Rain,risk_analysis_q6);
		$ques7r=risk_analysis($district,Rain,risk_analysis_q7);
		$ques8r=risk_analysis($district,Rain,risk_analysis_q8);
		$ques9r=risk_analysis($district,Rain,risk_analysis_q9);
		$ques10r=risk_analysis($district,Rain,risk_analysis_q10);
		$ques11r=risk_analysis($district,Rain,risk_analysis_q11);
		$arrr=array(1 => $ques1r, $ques2r, $ques3r, $ques4r, $ques5r, $ques6r, $ques7r, $ques8r, $ques9r, $ques10r, $ques11r);
		//echo $arrr[0];
		
		
		
		?>
				<td width="200" align="center">
				<span class="style10">Rain Tanka</span></td>
				
				<td width="314" align="center"><span class="style10">
				<?php 
				if($arrr[1]==0 && $arrr[2]==0 && $arrr[3]==0 && $arrr[4]==0 && $arrr[5]==0 && $arrr[6]==0 && $arrr[7]==0 && $arrr[8]==0 && $arrr[9]==0 && $arrr[10]==0 && $arrr[11]==0)
				{
					echo '';
				}
				else
				{
					arsort($arrr);
					$num_print=0;
					foreach ($arrr as $keyr => $valr) {
					//echo $arr[0];
					echo "Question" . $keyr . "<br>";
					if (++$num_print == 3) {
					break;
					}
					//echo arr1;
					}
				}
				 ?>
				</span></td>
			</tr>
		</table>		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>


</body>

</html>